package com.asen.commons.core.base.listener;

import org.springframework.context.ApplicationEvent;

import java.util.Map;

/**
 * 全局事件
 *
 * @author Gary
 * @version 1.0
 * @date 2022-07-29
 */
public class GlobalEvent extends ApplicationEvent {

    private String billType;

    private Long billId;

    private Map<String, Object> data;

    public GlobalEvent(String eventType) {
        super(new GlobalEventSource(eventType));
    }

    public String getBillType() {
        return billType;
    }

    public void setBillType(String billType) {
        this.billType = billType;
    }

    public Long getBillId() {
        return billId;
    }

    public void setBillId(Long billId) {
        this.billId = billId;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public String getEventType() {
        GlobalEventSource source = (GlobalEventSource) getSource();
        return source.getEventType();
    }

    @Override
    public String toString() {
        return "GlobalEvent{" +
                "eventType='" + getEventType() + '\'' +
                ", timestamp=" + getTimestamp() +
                ", billType='" + billType + '\'' +
                ", billId=" + billId +
                ", data=" + data +
                '}';
    }
}
